home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / Updates / HD-Installer / jst_dev / sources / src / loaders / Beast3 / SOTB3hd.asm < prev    next >
Assembly Source File  |  2000-04-12  |  6KB  |  445 lines

  1.  
  2. ; *** Shadow Of The Beast 3 Hard Disk Loader V1.1a
  3. ; *** Written by Jean-François Fabre
  4.  
  5.     include    "jst.i"
  6.  
  7.     HD_PARAMS    "",0,0
  8.  
  9. COMM_NONE = 0
  10. COMM_PAUSE = 1
  11. COMM_RESTART = 3
  12.  
  13.  
  14. _loader:
  15.     RELOC_MOVEL    D0,trainer
  16.     RELOC_MOVEL    D2,joypad
  17.  
  18.     Mac_printf    "Shadow Of The Beast 3 HD Loader V1.2a"
  19.     Mac_printf    "Programmed by Jean-François Fabre © 1997"
  20.  
  21.     lea    mainname(pc),A0
  22.     move.l    A0,D0
  23.     JSRABS    TestFile
  24.     tst.l    D0
  25.     bne    MainErr
  26.  
  27.     ; ** test if a file from disk 2 is here (to see if disk 2 has been installed)
  28.  
  29.     lea    f40name(pc),A0
  30.     move.l    A0,D0
  31.     JSRABS    TestFile
  32.     tst.l    D0
  33.     bne    MainErr
  34.  
  35.     move.l    #5000,D0
  36.     JSRABS    LoadSmallFiles
  37.  
  38. ;    bsr    MemoryConfig
  39.  
  40.     moveq.l    #0,D0
  41.     move.l    #CACRF_CopyBack,D1
  42.     JSRABS    Degrade
  43.  
  44. ;    WAIT_LMB
  45.  
  46.     GO_SUPERVISOR
  47.     SAVE_OSDATA    $80000
  48.  
  49.     lea    $80000,A7
  50.     JSRGEN    FreezeAll
  51.     move    #$2700,SR
  52.  
  53.     move.l    ExtBase(pc),D0
  54.     MOVE.L    ExtSize(pc),D1
  55.     MOVE.l    ExtFlag(pc),D2
  56.  
  57.     MOVE.L    D0,$4.W        ; extension base pointer
  58.     MOVE.L    D1,$8.W        ; memory extension size
  59.  
  60.     ; *** read the file 'main'
  61.  
  62.     lea    mainname(pc),A0
  63.     lea    $70000,A1    
  64.     moveq.l    #0,D0
  65.     moveq.l    #-1,D1
  66.     JSRGEN    ReadFile
  67.  
  68.     bsr    PatchMain
  69.     GETUSRADDR    PatchLoader1
  70.     move.l    D0,$BC.W
  71.  
  72.     ; *** flush the caches (just in case)
  73.  
  74.     JSRGEN    FlushCachesHard
  75.  
  76.     ; *** and start the dance
  77.  
  78.     JMP    $7001A
  79.  
  80.  
  81. PatchMain:
  82.     lea    version(pc),A4
  83.  
  84.     cmp.l    #$01E02049,$70100
  85.     bne    not_pal$
  86.  
  87.     ; *** removes a check for NTSC
  88.     ; *** (both versions are country-protected)
  89.  
  90.     move.b    #$60,$7008A
  91.  
  92.     move.l    #1,(A4)
  93.     bra    verok$
  94.  
  95. not_pal$    
  96.     cmp.l    #$C7806100,$70100
  97.     bne    not_ntsc$
  98.  
  99.     ; *** NTSC version
  100.  
  101.     ; *** removes a check for PAL
  102.     ; *** (both versions are country-protected)
  103.  
  104.     move.w    #$4E71,$7008A
  105.  
  106.     move.l    #2,(A4)
  107.     bra    verok$
  108.  
  109.     ; *** unrecognized version: quit
  110.  
  111. not_ntsc$
  112.     lea    UnrecogErr(pc),A0
  113.     JSRGEN    SetExitRoutine
  114.     JSRGEN    InGameExit
  115. verok$
  116.     ; *** patch the file
  117.  
  118.     lea    $70684,A0
  119.     cmp.l    #2,(A4)
  120.     bne    1$
  121.  
  122.     ; *** NTSC version is shifted by 4 bytes
  123.  
  124.     lea    $4(A0),A0
  125. 1$
  126.     GETUSRADDR    DiskRoutine
  127.     move.w    #$4EF9,(A0)+
  128.     move.l    D0,(A0)
  129.  
  130.     lea    $702C4,A0
  131.     cmp.l    #2,(A4)
  132.     bne    2$
  133.  
  134.     ; *** NTSC version is shifted by 4 bytes
  135.  
  136.     lea    $4(A0),A0
  137. 2$
  138.  
  139.     move.w    #$4E4F,(A0)
  140.     rts
  141.  
  142. PatchLoader1:
  143.     STORE_REGS
  144.  
  145.     ; *** patch the disk routine
  146.     
  147.     PATCHUSRJMP    $6B4D2,DiskRoutine
  148.  
  149.     ; *** remove a mask of the memory zone
  150.     ; *** which overrides some of the memory
  151.  
  152.     move.w    #$6024,$4AFC.W
  153.     
  154.     ; *** installs the quit patch (menu)
  155.  
  156.     PATCHUSRJSR    $7BEE.W,kbint2
  157.  
  158.     ; *** installs the quit patch (in game)
  159.  
  160.     PATCHUSRJSR    $7D10.W,kbint
  161.     move.w    #$4E71,$7D16
  162.  
  163.     ; *** activates the original cheat keys
  164.  
  165.     move.w    #$4E71,$7D2C.W
  166.  
  167.     ; *** patch for joypad
  168.  
  169.     move.l    joypad(pc),D0
  170.     beq    sk$
  171.     
  172.     PATCHUSRJSR    $7BD0.W,CheckJoypad
  173.     PATCHUSRJMP    $7778.W,JoyPatch
  174.  
  175. sk$
  176.  
  177.     ; *** and starts the main program
  178.  
  179.     JSRGEN    GoECS
  180.     JSRGEN    FlushCachesHard
  181.  
  182.     RESTORE_REGS
  183.     jmp    $256.W
  184.  
  185. CheckJoypad:
  186.     movem.l    D0/A0,-(sp)
  187.     cmp.b    #$7F,($29A).W    ; space pressed
  188.     bne.b    sksp$
  189.     lea    spaceemu(pc),A0
  190.     tst.l    (A0)
  191.     beq.b    sksp$
  192.     clr.l    (A0)
  193.     move.b    #$7E,($29A).W    ; space released
  194. sksp$
  195.  
  196.     moveq.l    #1,D0
  197.     JSRGEN    JoypadState
  198.     tst.w    D0
  199.     beq    exit$
  200.  
  201.     lea    command(pc),A0
  202.  
  203.     ; ** button 2: change weapon
  204.     
  205.     btst    #AFB_FIRE2,D0
  206.     beq.b    1$
  207.  
  208.     lea    spaceemu(pc),A0
  209.     move.l    #1,(A0)
  210.     move.b    #$7F,($29A).W        ; space pressed
  211.     bra    exit$
  212.  
  213.     ; ** start: pause
  214. 1$
  215.     btst    #AFB_START,D0
  216.     beq.b    2$
  217.  
  218.     move.l    #COMM_PAUSE,(A0)
  219.     bra.b    exit$
  220.  
  221.     ; ** forward: cheat on
  222. 2$
  223.  
  224.     btst    #AFB_FORWD,D0
  225.     beq.b    3$
  226.     move.b    #1,$2CB.W
  227.     bra.b    exit$
  228.  
  229.     ; ** back: cheat off
  230.  
  231. 3$
  232.     btst    #AFB_BACWD,D0
  233.     beq.b    4$
  234.     clr.b    $2CB.W
  235.     bra.b    exit$
  236.  
  237.     ; *** green: restart part
  238. 4$
  239.     btst    #AFB_FIRE3,D0
  240.     beq.b    5$
  241.  
  242.     move.l    #COMM_RESTART,(A0)
  243.     bra.b    exit$
  244. 5$
  245. exit$
  246.     movem.l    (sp)+,D0/A0
  247.     move.w    #$20,(intreq,A6)
  248.     rts
  249.  
  250. JoyPatch:
  251. loop$
  252.     move.l    D0,-(sp)
  253.     move.l    command(pc),D0
  254.     bne.b    action$
  255.     move.l    (sp)+,D0
  256. cont$
  257.     tst.b    ($30E).W
  258.     beq.b    loop$
  259.     rts
  260.  
  261. action$
  262.     move.l    A0,-(sp)
  263.     lea    command(pc),A0
  264.     clr.l    (A0)
  265.     move.l    (sp)+,A0    
  266.  
  267.     cmp.l    #COMM_RESTART,D0
  268.     beq.b    rest$
  269.  
  270.     cmp.l    #COMM_PAUSE,D0
  271.     beq.b    pause$
  272.  
  273.     move.l    (sp)+,D0
  274.     bra.b    cont$
  275.  
  276. weapon$
  277.     move.l    (sp)+,D0
  278.     jmp    ($7E0C).W    
  279.  
  280. pause$
  281.     move.l    (sp)+,D0
  282.     jmp    ($7DF4).W    
  283. rest$
  284.     move.l    (sp)+,D0
  285.     jmp    ($7E68).W
  286.  
  287. DiskRoutine:
  288.     cmp.b    #5,D1
  289.     beq    DR_DirRead
  290.     cmp.b    #0,D1
  291.     beq    DR_FileRead
  292.  
  293.     moveq.l    #0,D0
  294.     bra    DR_End
  295.  
  296.     ; *** load the file
  297.  
  298. DR_FileRead:
  299.     moveq.l    #0,D0
  300.     moveq.l    #-1,D1
  301.  
  302.     JSRGEN    ReadFile
  303.     tst.l    D0
  304.     bmi    DR_Error    ; not found : fatal error : quit
  305.  
  306.     move.l    D0,D1
  307.     moveq.l    #0,D0
  308.     bra    DR_End
  309.  
  310. ; *** read directory
  311.  
  312. DR_DirRead:
  313.     moveq.l    #0,D0
  314.     moveq.l    #0,D1
  315. DR_End:
  316.     MOVEM.L    (A7)+,D2-D7/A0-A6
  317.     RTS
  318.  
  319. ; *** other commands, still not supported
  320.  
  321. DR_Other:
  322.     cmp.w    #1,D1
  323.     beq    DR_FileWrite
  324. DR_Error:
  325.     lea    FileNotFound(pc),A0
  326.     JSRGEN    SetExitRoutine
  327.     JSRGEN    InGameExit
  328.     bra    DR_Error
  329.  
  330. ; *** write file (not used in SOTB3)
  331. ; D0 holds the length to write but we ignore it
  332. ; because we write only the scores
  333.  
  334. DR_FileWrite:
  335.     moveq.l    #-1,D0
  336.     moveq.l    #0,D1
  337.     bra    DR_End
  338.  
  339.  
  340. kbint2:
  341.     move.b    $BFEC01,D0
  342.     move.l    D0,-(sp)
  343.     ror.b    #1,D0
  344.     not.b    D0
  345.     cmp.b    #$54,D0    ; raw keycode for F5
  346.     bne    noquit$
  347.     JSRGEN    InGameExit
  348. noquit$
  349.     move.l    (sp)+,D0
  350.     tst.b    $BFEC01
  351.     rts
  352.  
  353. kbint:
  354.     cmp.b    #$57,D0    ; their code for F5
  355.     bne    noquit$
  356.     JSRGEN    InGameExit
  357. noquit$
  358.     cmp.b    #$75,D0    ; original game
  359.     bne    nothing$
  360.     jmp    $7E58.W
  361. nothing$    
  362.     rts
  363.  
  364.  
  365. LocalPatchExcept:
  366.     move.l    $8.W,-(sp)    ; used by the game to store data
  367.     JSRGEN    PatchExceptions
  368.     move.l    (sp)+,$8.W
  369.     rts
  370.  
  371. MemoryConfig:
  372.     move.l    #$100000,D0
  373.     JSRABS    AllocExtMem
  374.     RELOC_MOVEL    D0,ExtBase
  375.     beq    not1MB$
  376.  
  377.     RELOC_MOVEL    #$100000,ExtSize
  378.     RELOC_MOVEL    #$0F0,ExtFlag
  379.     bra    suite$
  380. not1MB$
  381.     move.l    #$80000,D0
  382.     JSRABS    AllocExtMem
  383.     RELOC_MOVEL    D0,ExtBase
  384.     beq    not512Fast$
  385.  
  386.     RELOC_MOVEL    #$80000,ExtSize
  387.     RELOC_MOVEL    #$00F,ExtFlag
  388.     bra    suite$
  389.  
  390. not512Fast$:
  391.     ; *** only the 512K chipmem used
  392.     RELOC_CLRL    ExtSize
  393.     RELOC_CLRL    ExtFlag
  394.     RELOC_CLRL    ExtBase
  395.  
  396. suite$
  397.     rts
  398.  
  399.  
  400.  
  401.     ; ** in case the user tries to run the game without having installed
  402.     ; ** the game properly
  403.  
  404. MainErr:
  405.     Mac_printf    "** File ''main'' missing or disk 2 not installed."
  406.     Mac_printf    "   Please install the game properly and try again !!"
  407.     JMPABS    CloseAll
  408.  
  409. MemErr:
  410.     Mac_printf    "** Not enough memory to run Shadow Of The Beast III"
  411.     JMPABS    CloseAll
  412.  
  413. FileNotFound:
  414.     Mac_printf    "** Run-time error: a file is missing."
  415.     Mac_printf    "   Please install the game properly and try again !!"
  416.     JSRABS    WaitReturn
  417.     rts
  418.  
  419. UnrecogErr:
  420.     Mac_printf    "** Version of game not supported"
  421.     Mac_printf    "   Please contact the author!"
  422.     JSRABS    WaitReturn
  423.     rts
  424.  
  425. trainer:
  426.     dc.l    0
  427. joypad:
  428.     dc.l    0
  429. spaceemu:
  430.     dc.l    0
  431. ExtBase:
  432.     dc.l    0
  433. ExtSize:
  434.     dc.l    0
  435. ExtFlag:
  436.     dc.l    0
  437. version:
  438.     dc.l    0
  439. command:
  440.     dc.l    0
  441. mainname:
  442.     dc.b    "main",0
  443. f40name:
  444.     dc.b    "f40",0
  445.